package SourceMap;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.util.StringUtils;

import java.math.BigDecimal;

public class PressABookSourceMap implements MapFunction<String, Tuple3<String,Long,String>> {
    @Override
    public Tuple3<String,Long,String> map(String s) throws Exception {

        if(StringUtils.isNullOrWhitespaceOnly(s)) {
            System.out.println("invalid line");
            return null;
        }
        String[] array = s.split("\\|");

        if(null==array || array.length<7) {
            System.out.println("invalid line for array");
            return null;
        }
        try {
            String bigStr = new BigDecimal(array[4]).toString();
        } catch (Exception e) {
            return new Tuple3<>("错误",0L,"错误");
        }
        //记录省份
//        System.out.println(array[4]);
        return new Tuple3<>(array[2],Long.valueOf(array[4]),array[6]);
    }
}
